﻿(function () {
    'use strict';

    function announcementMapper() {
        function toAnnouncements(announcementsRaw) {
            var dataSet = [];
            angular.forEach(announcementsRaw, function (e) {
                dataSet.push({
                    title: e.Title,
                    status: e.Status
                });
            });
            console.table(announcementsRaw);
            return dataSet;
        }

        function toRawAnnouncements(announcements) {
            var dataSet = [];
            angular.forEach(announcements, function (e) {
                dataSet.push({
                    Title: e.title,
                    Status: e.status
                });
            });
            console.table(announcements);
            return dataSet;
        }
        var service = {
            toAnnouncements: toAnnouncements,
            toRawAnnouncements: toRawAnnouncements
        };

        return service;
    }

    angular
        .module('SpaDemo')
        .factory('announcementMapper', announcementMapper);

    announcementMapper.$inject = [];
})();